package com.zeei.ems.base.service.impl;

import com.zeei.ems.base.dao.RiverDao;
import com.zeei.ems.base.service.RiverService;
import com.zeei.ems.base.tree.TreeNodeVO;
import com.zeei.ems.base.util.StringUtil;
import com.zeei.ems.base.util.TreeUtil;
import com.zeei.ems.base.vo.RiverParam;
import com.zeei.ems.base.vo.RiverVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;


@Service
public class RiverServiceImpl implements RiverService {
    @Autowired
    RiverDao riverDao;

    @Override
    public List<TreeNodeVO<RiverVO>> queryRiverByCondition(RiverParam riverParam) {
        List<TreeNodeVO<RiverVO>> resultList;
        List<RiverVO> riverList = riverDao.queryRiverByCondition(riverParam);
        if (!CollectionUtils.isEmpty(riverList)){
            resultList = TreeUtil.buildTreeNodeTree(riverList, StringUtil.empty());
        }else{
            resultList = new ArrayList<>();
        }

        return resultList;
    }
}
